#pragma once

#include <functional>
#include <QRunnable>
#include <QThreadPool>
#include <QDebug>
namespace Util {

typedef std::function<int()> threadpool_func_t;

class ThreadPool : public QRunnable
{
public:
    ThreadPool(threadpool_func_t funcObj) {
        m_funcObj = funcObj;
        setAutoDelete(false);
        QThreadPool::globalInstance()->tryStart(this);
    }
    ~ThreadPool() = default;
    void run() override
    {
        m_funcObj();
    }
private:
    threadpool_func_t m_funcObj;
};
}
